home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / HELP.DOC < prev    next >
Text File  |  1990-11-29  |  50KB  |  977 lines

  1.  
  2. ;Video routine short instruction list
  3.  
  4. ========================================================================
  5.     Copyright (C) Copr. 1990 by Sidney J. Kelly
  6.             All Rights Reserved.
  7.             Sidney J. Kelly
  8.             150 Woodhaven Drive
  9.             Pittsburgh, PA 15228
  10.             home phone 412-561-0950 (7pm to 9:30pm EST)
  11.  
  12.      CompuServ   70043,1656
  13.      Genie       S.KELLY8
  14.  
  15. ========================================================================
  16.  
  17.           The following routines are designed to do something
  18. useful to text without regard to the type of monitor actually
  19. installed.  These routines are text mode primitives.  In most
  20. cases that give you direct control over the hardware in a fashion
  21. that cannot be done except in assembly language.  You can save
  22. the display, write characters or attributes at high speed to the
  23. display, or write to the display using DOS compatible modes to
  24. allow you to use multi-taskers or ANSI.SYS.  You can change text
  25. or attributes on the display.  You can adjust cursor size, turn
  26. off blinking, BLOAD help files, etc.
  27.           These routines are part of a larger freeware library of
  28. QBASIC routines that is currently under construction.  The full
  29. version will be released two days AFTER an OOPS version of QBASIC
  30. is released by MICROSOFT-- at which time few will want to use
  31. these routines.
  32.           Why these were written:
  33.           I originally wrote these routines to parrot Dick Evers
  34. window routines written exclusively in BASIC (You can see his
  35. influence in the demo program).  Then an old issue of PC Magazine
  36. showed how to call MASM video routines from QBASIC, which I think
  37. is based on an earlier BYTE magazine article.  Other PC Magazine
  38. routines, and the discussions about IBM Technical reference video
  39. adapter recognition routines, showed how to identify display
  40. types using just BIOS calls.  Then the quest began: I began my
  41. search of back issues of PC Magazine for programming tidbits, I
  42. bought old assembly language guide books back with the earth was
  43. fresh and the IBM PC with 64kb of memory and two floppies was a
  44. wonder to behold, searched the standard databases for public
  45. domain routines; read more programming books, etc.  The
  46. bibliography at the end of this document should answer your
  47. requests for additional information.
  48.           The video display was selected for improvement because
  49. that is one area a user can really notice the difference between
  50. fast code and slow code.  Some of these routines allow you to do
  51. things that are impossible otherwise.  Other routines allow you
  52. to do something much faster and in an attractive fashion.  All
  53. the routines avoid the agony of using ON ERROR GOTO traps.
  54.           Programmers Assumptions:           These routines are designed to work with MONO, CGA,
  55. HERC, MCGA (mostly color, though generally untested), EGA (mono
  56. or color, 25 or 43 line mode), and VGA (mono or color, 25 or 50
  57. line mode).  In a very limited way, the routines support dual
  58. displays.  These routines assume that the display width is 80
  59. columns wide, mostly because there is no known way to determine
  60. in advance if a particular user's display will support 132 column
  61. mode.  Anyway that is QBASIC's assumption too.  More importantly
  62. I don't own a multi sync display, and I do not access to 10 types
  63. of EGA and 50 types of VGA displays that are necessary to test
  64. everything out on.  Finally, there are several shareware
  65. libraries that already have some of the ATI, Paradise, VESA and
  66. Video Seven EGA/VGA routines built in.  Unfortunately, after
  67. looking at the freeware version of FRACINT (a nifty graphics time
  68. waster that draws fractals), it appears that there are about five
  69. or six different ways to switch displays into high resolution
  70. mode.  Even FRACINT requires the user to select the display type.
  71. (How can I convince my wife that I need a register compatible
  72. 8514/A display and adapter for the ultimate in text mode
  73. displays??????????).
  74.           It is possible to devote many hours to routines for
  75. hardware 95% of the users wont have or need in text mode.  Most
  76. of the direct screen routines use macros that are hard coded for
  77. an 80 column width display. (Lengths of 25, 43, and 50 are
  78. allowed).  This is done for speed in case the poor user only has
  79. a CGA on a PC clone (he needs all the speed he can get).  To show
  80. how it is done, I have included a few routines that actually do
  81. use the BIOS ram data areas to determine the current display
  82. width.
  83.           QBASIC Theory.
  84.           Aside from the current DEF SEG setting, most of QBASIC
  85. video information storage registers are not available inside the
  86. QB.EXE environment, though it is available inside the .EXE
  87. program (which makes testing the routines way too time
  88. consuming).  My routines had to come up with such information
  89. independently.  My solution is store the key variables in the
  90. default data segment in QBASIC (its name in MASM is DGROUP).  To
  91. save space in DGROUP, only 7 bytes of information is kept by the
  92. video routines.  This allows transparent sharing of the
  93. information.  The reason for such "stupid" names (B$V...) for the
  94. DGROUP variables is to only give the MASM routines access to such
  95. information, and prevent normal QBASIC routines (or someone
  96. else's library routines) from messing them up.
  97.           Generally QBASIC only keeps simple variables, (INT,
  98. LONGINT, SINGLE and DOUBLE, and STRINGS) in DGROUP.  Arrays and
  99. TYPE records are usually kept outside DGROUP, with only the
  100. STRING Descriptor or the undocumented Array descriptor kept in
  101. DGROUP.  Thus, the library routines assume that all information
  102. passed from simple variables is information about a near (DGROUP)
  103. address.  If we pass simple integers to MASM routines, and don't
  104. care to have MASM change those variables, we use BYVAL to send
  105. the information to MASM.  If we want to have MASM send
  106. information back about multiple variables, we pass the address
  107. information for the variables without using BYVAL.  If we use arrays, we must use a combination of BYVAL and VARSEG and VARPTR
  108. to get the information we need to manipulate the information
  109. inside the arrays.  VARSEG and VARPTR are necessary because there
  110. is a very great chance that the arrays will be stored as far data
  111. (i.e. not stored in DGROUP).
  112.           Text strings are sent by QBASIC as near address
  113. (relative to DS and DGROUP).  The fist value in the descriptor is
  114. the length of the string.  The second value is the offset address
  115. inside DGROUP.  Fixed length strings are not referenced with
  116. string descriptors.  For that reason, I don't allow such strings
  117. as variables in my routines.
  118.           QBASIC requires that MASM preserve BP, SI, DI, DS, and
  119. keep the direction flag clear (CLD).  All these routines do this.
  120. You will note that MICROSOFT'S CALL INTERRUPT routines do not
  121. save BP (apparently to give you access to some EGA VGA palette
  122. and character font selection routines in the BIOS), and thus will
  123. crash if a critical error occurs.  MICROSOFT offers a replacement
  124. routine, that overcomes this error by preventing any change to
  125. BP.  You should get it if you don't already have it.
  126.           The choice of defining MASM routines as SUB's or
  127. FUNCTION's depends on whether you want to get information from
  128. MASM in DX:AX (the format for FUNCTIONs), or if the MASM routine
  129. either sends back no information or more than one variable (the
  130. format for SUBs).  For simple one variable routines when MASM is
  131. just returning a value, use FUNCTIONs.  To use such functions
  132. inside QBASIC you must either assign the value of the function to
  133. a QBASIC variable or use IF ... THEN statements (C style).  For
  134. everything else use SUBS.
  135.           Note due to an error in the QBASIC parser, always use
  136. the CALL keyword to call the library routines if there is any
  137. chance that you will use a colon as a separator on a line.
  138. Without the CALL keyword, the QBASIC parser assumes that the
  139. routine name followed by a colon is intended as a line label, and
  140. not as a SUB name.  You must use CALL if you will use a SUB that
  141. does not need any parameters and will